home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / THIN C 2.0 / Projects / listPrimes / listPrimes.c next >
Encoding:
C/C++ Source or Header  |  1991-05-03  |  361 b   |  27 lines  |  [TEXT/THIN]

  1. #include <stdio.h>
  2.  
  3.  
  4. IsItPrime( int    candidate )
  5. {
  6.     int    i, foundFactor;
  7.     
  8.     foundFactor = FALSE;
  9.     for ( i = 2; i < candidate; i++ )
  10.     {
  11.         if ( (candidate / i) * i == candidate )
  12.             foundFactor = TRUE;
  13.     }
  14.     
  15.     return( foundFactor == FALSE );
  16. }
  17.  
  18. main()
  19. {
  20.     int    i;
  21.     
  22.     for ( i = 1; i <= 50; i++ )
  23.     {
  24.         if ( IsItPrime( i ) )
  25.             printf( "%d is a prime number.\n", i );
  26.     }
  27. }